package com.cloud.code.牛客网;

import java.util.*;

public class Test12 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int[] g = new int[n];
            for (int i = 0; i < n; i++) {
                g[i] = in.nextInt();
            }

            int[] num = new int[n];
            for (int i = 0; i < n; i++) {
                num[i] = in.nextInt();
            }

            //默认0是一种
            Set<Integer> set = new HashSet<>();
            set.add(0);

            for (int i = 0; i < g.length; i++) {
                //这里初始化一个容器， 相当于记录当前set里面的所有类型
                List<Integer> list = new ArrayList<>(set);

                //注意这里其实就是遍历个数
                for (int j = 1; j <= num[i]; j++) {

                    for (int k = 0; k < list.size(); k++) {
                        set.add(list.get(k) + g[i] * j);
                    }
                }
            }
            System.out.println(set.size());
        }
    }
}
